package com.test.io.streamrReader;

import org.junit.Test;

import java.io.*;

/**
 * @version 1.0
 * @Author: 许啸林 输入字节转换流练习 InputStreamReader(InputStream, character) 可将字节流转换成指定编码的字符流
 * @Date: 2021/6/4 11:04
 */
public class InputStreamReaderDemo {
    @Test
    public void read() {
        BufferedReader bufferedReader = null;
        try {
            FileInputStream is = null;
            is = new FileInputStream("d:\\newFile3.txt");
            // 处理流可包装转换流(修饰者)
            bufferedReader = new BufferedReader(new InputStreamReader(is, "utf-8"));
            System.out.println(bufferedReader.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
